package lee.study.TestSort;

import java.util.Arrays;

public class shellSort {
    public static void shell(int[] array, int gap) {
        int tmp = 0;
        for (int i = gap; i < array.length; i++) {
            tmp = array[i];
            int j;
            for (j = i - gap; j >= 0; j -= gap) {
                if (array[j] > tmp) {
                    array[j + gap] = array[j];
                } else {
                    break;
                }
            }
            array[j + gap] = tmp;
        }
    }

    public static void shellSort1(int[] array) {
        int[] drr = {5, 3, 1};
        for (int i = 0; i < drr.length; i++) {
            shell(array, drr[i]);
        }
    }

    public static void main(String[] args) {
        int[] array = {1, 7, 3, 9, 2, 98, 24, 91, 65};
        shellSort1(array);
        System.out.println(Arrays.toString(array));
    }
}
